<template>
	<section>
		<p>亲爱的
			<strong> {{user.name}} </strong>您好，欢迎回来。</p>
		<p>当前时间为：{{data}}。</p>
	</section>
</template>

<script>
export default {
	name: 'main',
	data() {
		return {
			user: null,
			data: ''
		}
	},
	beforeMount: function() {
		let today = new Date()
		let y = today.getFullYear()
		let M = today.getMonth() + 1
		let d = today.getDate()
		let h = today.getHours()
		let m = today.getMinutes()
		let s = today.getSeconds()
		let D = today.getDay()
		M = this.checkTime(M)
		d = this.checkTime(d)
		h = this.checkTime(h)
		m = this.checkTime(m)
		s = this.checkTime(s)

		let week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
		this.user = JSON.parse(sessionStorage.getItem('user'))
		this.data = y + '-' + M + '-' + d + ' ' + h + ':' + m + ':' + s + ' ' + week[D]
	}
}

</script>

<style scoped>
section {
	width: 100%;
	height: 150px;
}

p {
	text-indent: 30px;
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
	font-size: 15px;
	color: #1F2D3D;
}

p strong {
	color: #FF4949;
}
</style>